﻿@model QuanLyGiaoVuUI.Models.CaiDatViewModel
@{
    Layout = "~/Views/Shared/_blueWhaleLayout.cshtml";
}

<style>
    td.label-cell {
        width: 150px;
    }

    table {
        border-collapse: collapse;
    }

    .hidden {
        display: none;
    }
</style>

@{Html.RenderPartial("CaiDatMenuPartial");}
<div class="grid_10">
    <div class="box round first grid">
        <h2>Cài đặt</h2>
        <div class="block">
            @{using (Ajax.BeginForm("LuuCaiDat", "CaiDat", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "hockyhientaiId", OnSuccess = "ThongBao" }))
              {
                <table class="form">
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.HocKyHienTai)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.DropDownListFor(m => m.HocKyHienTai, new SelectList(Model.DanhSachHocKy, "MaHocKy", "TenHocKyDayDu"))
                                @Html.ValidationMessageFor(model => model.HocKyHienTai)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.HocKyTiepTheo)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.DropDownListFor(m => m.HocKyTiepTheo, new SelectList(Model.DanhSachHocKy, "MaHocKy", "TenHocKyDayDu"))
                                @Html.ValidationMessageFor(model => model.HocKyTiepTheo)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.ChoPhepDangKyDeTai)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.CheckBoxFor(m => m.ChoPhepDangKyDeTai)
                                @Html.ValidationMessageFor(model => model.ChoPhepDangKyDeTai)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.SoTinChiToiThieu)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.TextBoxFor(m => m.SoTinChiToiThieu, new {@class="isSpinner" })
                                @Html.ValidationMessageFor(model => model.SoTinChiToiThieu)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.ChoPhepSVDangKyDeTai)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.CheckBoxFor(m => m.ChoPhepSVDangKyDeTai)
                                @Html.ValidationMessageFor(model => model.ChoPhepSVDangKyDeTai)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.ChoPhepXacNhanLop)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.CheckBoxFor(m => m.ChoPhepXacNhanLop)
                                @Html.ValidationMessageFor(model => model.ChoPhepXacNhanLop)
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="label-cell">
                            <div class="editor-label">
                                @Html.LabelFor(model => model.ChoPhepDangKyLichThi)
                            </div>
                        </td>
                        <td>
                            <div class="editor-field">
                                @Html.CheckBoxFor(m => m.ChoPhepDangKyLichThi)
                                @Html.ValidationMessageFor(model => model.ChoPhepDangKyLichThi)
                            </div>
                        </td>
                    </tr>
                    <tr id="thoiGianThi" @(Model.ChoPhepDangKyLichThi ? "" : "class='hidden'")>
                        <td class="label-cell">
                            <div class="editor-label">
                                <label>Thời gian tổ chức thi học kỳ</label>
                            </div>
                        </td>
                        <td>
                            <span>Từ ngày </span>
                            <div class="editor-field">
                                @Html.TextBox("BatDauLichThi", Model.BatDauLichThi.ToShortDateString(), new { @class = "date_picker" })
                                @Html.ValidationMessageFor(model => model.BatDauLichThi)
                            </div>
                            <span>Đến ngày </span>
                            <div class="editor-field">
                                @Html.TextBox("KetThucLichThi", Model.KetThucLichThi.ToShortDateString(), new { @class = "date_picker" })
                                @*<input type="text" class="date_picker" value='@String.Format("{0}/{1}/{2}",Model.KetThucLichThi.Day, Model.KetThucLichThi.Month, Model.KetThucLichThi.Year)' id="datePickerKetThucLichThi" />*@
                                @Html.ValidationMessageFor(model => model.KetThucLichThi)
                            </div>
                        </td>
                    </tr>
                </table>
                <input type="submit" value="Lưu" />
              }
            }
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $(".date_picker").datepicker();
        $(".isSpinner").spinner({
            min: 50
        });
        $("#ChoPhepDangKyLichThi").is(":checked") ? $("#thoiGianThi").removeClass("hidden") : $("#thoiGianThi").addClass("hidden");
        $("#ChoPhepDangKyLichThi").bind("change", function () {
            $(this).is(":checked") ? $("#thoiGianThi").removeClass("hidden") : $("#thoiGianThi").addClass("hidden");
        });

    });

    function ThongBao(data) {
        if (data.success)
            ToastManager.showSuccessToast("Cập nhật thành công.");
        else {
            ToastManager.showStickyWarningToast(data.message);
        }
    }
</script>
